# -*- coding: utf-8 -*-
class Node():
    def __init__(self, data=None, next=None):
        self._data = data
        self._next = next
    def setData(self, NewData):    
        self._data = NewData
    def setNext(self, NewNext):
        self._next = NewNext
    def getData(self):
        return self._data
    def getNext(self):
        return self._next
    
class LinkedList():
    def __init__(self):
        self._head = Node()
        self._length = 0
    def tail_add(self, NewData):
        NewNode = Node(NewData, None)
        if self._length == 0:
            self._head = NewNode
            self._length = 1
        else:
            current = self._head
            while current.getNext() != None:
                current = current.getNext()
            current.setNext(NewNode)
            self._length += 1
    def PrintLinkedList(self):
        curr = self._head
        while curr != None:
            print('打印节点：%s' % (curr.getData()))
            curr = curr.getNext()
    def getLength(self):
        return self._length
    def delNode(self, number):
        curr = self._head
        if self._length == 1:
            self._head = None
        else:
            next1 = curr.getNext()
            i = 2
            while i <= self._length:
                if i == number:
                    if i == self._length:
                        curr.setNext(None)
                        break
                    else:
                        next1 = curr.getNext()
                        curr.setNext(next1.getNext())
                        break
                else:
                    curr = next1
                    next = next1.getNext()
                    i += 1
        self._length -= 1
        
chicks = ['1号', '2号', '3号', '4号', '5号']
newLinked = LinkedList()
for s in chicks:
    newLinked.tail_add(s)
print(newLinked.getLength())
newLinked.PrintLinkedList()
print('删除3号小鸡')
newLinked.delNode(3)
newLinked.PrintLinkedList()